package org.springblade.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @Description 电梯事件上报类型
 * @Author ysq
 * @Date 2021/5/26
 **/
@Getter
@AllArgsConstructor
public enum EventType {
	TRAP_ELEVATOR_ALARM(0, "困梯报警"),
	REMNATS_ALARM(1, "遗留物报警"),
	MOTO_ENTER_ALARM (2, "电动车入梯报警"),
	SCREAM_ALARM (3, "尖叫报警"),
	SMOKING_ALARM (4, "抽烟报警"),
	REPEAT_OPEN_CLOSE_DOOR_ALARM (5, "反复开关门报警"),
	RUNNING_OPEN_DOOR_ALARM (6, "运行中开门报警"),
	OBSTRUCT_DOOR_ALARM (7, "遮挡门报警"),
	OVERSPEED_ALARM (8, "超速报警"),
	CHILDREN_TAKE_ELEVATOR_ALONE_ALARM (9, "儿童单独乘梯报警，一般指3岁以下小孩"),
	BABYCAR_TAKE_ELEVATOR_ALONE_ALARM (10, "婴儿车单独乘梯报警"),
	JUMPING_ALARM (11, "蹦跳报警"),
	FALL_DOWN_ALARM (12,"跌倒报警"),
	OPEN_DOOR_TIMEOUT_ALARM(13,"开门超时报警"), // 开门超时报警，达到楼层后，开门时间超过指定时间或平常统计的时间
	DOOR_OPEN_ALWAYS_ALARM(14,"门常开报警"),
	OPEN_DOOR_ANOMALY_ALARM(15,"开门异常报警"), // 开门异常报警，开门不到位-反关
	CLOSE_DOOR_ANOMALY_ALARM(16,"关门异常报警"), // 关门异常报警，关门不到位-反开
	DOOR_SPEED_ANOMALY_ALARM(17,"门速度异常报警"),
	LIGHT_CURTAIN_ANOMALY_ALARM(18,"光幕异常报警"),
	ANOMALY_NOISE_ALARM(19,"异常噪声报警"),
	EMERGENCY_STOP_ALARM(20, "急停报警"),   // 急停报警
	CANCEL_TRAP_ELEVATOR_ALARM (100, "撤销困梯报警"),
	CANCEL_REMNATS_ALARM (101, "撤销遗留物报警"),
	CANCEL_MOTO_ENTER_ALARM (102, "撤销电动车入梯报警"),
	CANCEL_SCREAM_ALARM (103, "撤销尖叫报警"),
	CANCEL_SMOKING_ALARM (104, "撤销抽烟报警"),
	CANCEL_REPEAT_OPEN_CLOSE_DOOR_ALARM (105, "撤销反复开关门报警"),
	CANCEL_RUNNING_OPEN_DOOR_ALARM (106, "撤销运行中开门报警"),
	CANCEL_OBSTRUCT_DOOR_ALARM (107, "撤销遮挡门报警"),
	CANCEL_OVERSPEED_ALARM (108, "撤销超速报警"),
	CANCEL_CHILDREN_TAKE_ELEVATOR_ALONE_ALARM (109, "撤销儿童单独乘梯报警，一般指3岁以下小孩"),
	CANCEL_BABYCAR_TAKE_ELEVATOR_ALONE_ALARM (110, "撤销婴儿车单独乘梯报警"),
	CANCEL_JUMPING_ALARM (111, "撤销蹦跳报警"),
	CANCEL_FALL_DOWN_ALARM (112, "撤销跌倒报警"),
	CANCEL_OPEN_DOOR_TIMEOUT_ALARM(113,"撤销开门超时报警"),
	CANCEL_DOOR_OPEN_ALWAYS_ALARM(114,"撤销门常开报警"),
	CANCEL_OPEN_DOOR_ANOMALY_ALARM(115,"撤销开门异常报警"),  // 撤销开门异常报警，此报警暂不作撤销
	CANCEL_CLOSE_DOOR_ANOMALY_ALARM(116,"撤销关门异常报警"), // 撤销关门异常报警，此报警暂不作撤销
	CANCEL_DOOR_SPEED_ANOMALY_ALARM(117,"撤销门速度异常报警"), // 撤销门速度异常报警，此报警暂不作撤销
	CANCEL_LIGHT_CURTAIN_ANOMALY_ALARM(118,"光幕异常报警"), // 光幕异常报警，此报警暂不作撤销
	CANCEL_ANOMALY_NOISE_ALARM(119,"异常噪声报警"); // 异常噪声报警，此报警暂不作撤销


	final Integer code;

	final String eventMsg;

	/**
	 * 根据code查询msg
	 * @param code
	 * @return
	 */
	public static String getMsgByCode(Integer code) {
		for (EventType type : EventType.values()) {
			if (type.getCode().equals(code)) {
				return type.getEventMsg();
			}
		}
		return null;
	}

	/**
	 * convert to map data
	 * @return
	 */
	public static Map<Integer, String> eventTypeMap() {
		Map<Integer, String> map = new HashMap<>(32);
		for (EventType type : EventType.values()) {
			map.put(type.getCode(),type.getEventMsg());
		}
		return map;
	}
}
